package net.xiaosaguo.mymall.search.controller;

import net.xiaosaguo.mymall.search.service.MallSearchService;
import net.xiaosaguo.mymall.search.vo.SearchParam;
import net.xiaosaguo.mymall.search.vo.SearchResult;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;

import javax.annotation.Resource;

/**
 * description: 检索页面 控制器
 *
 * @author xiaosaguo
 * @date 2020/06/27
 */
@Controller
public class SearchController {

    @Resource
    MallSearchService mallSearchService;

    @GetMapping({"/", "/index.html", "/list.html", "/search.html"})
    public String searchIndex(SearchParam searchParam, Model model) {

        SearchResult result = mallSearchService.search(searchParam);
        model.addAttribute("result", result);
        return "search";
    }
}
